<%@page import="com.alibaba.fastjson.JSONObject"%>
<%@page import="com.alibaba.fastjson.JSONArray"%>
<%@page import="com.alibaba.fastjson.JSON"%>
<%@page import="cn.pzhu.pojo.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>用户注册</title>
<script src="js/jquery-3.7.0.min.js"></script>
<style type="text/css">
	input[type="text"],input[type="password"]{
		width: 300px;
	}
	.error{
		 display: none; 
		 color:red;
	}
</style>
</head>
<script src="./js/regist.js" type="text/javascript" charset="utf-8"></script>
<body>
<jsp:include page="/common.jsp"/>
<h1 class="title">个人信息</h1>
</body>
	<c:choose>
		<c:when test='${empty user}'>未接收到数据</c:when>
		<c:otherwise>
			<form action="modify" method="post" onsubmit="check_regist(true)">
				<table style="margin:auto;">
					<tr>
						<td>账号</td>
						<td>
							<input type="text" name="username" value='${user.username}' readonly>
						</td>
					</tr>
					<tr>
						<td>
							<input type="hidden" name="password" value='${user.password}' readonly/>
						</td>
					</tr>
					<tr>
						<td>Email</td>
						<td><input type="text" name="email" value='${user.email}' onchange = "check_regist()"><span class="error" id='email_error'>邮箱格式错误!</span></td>
					</tr>
					<tr>
						<td>性别</td>
						<td>
								<input type="radio" name="gender" value="1" ${user.gender==1?'checked':''}>男
								<input type="radio" name="gender" value="0" ${user.gender==0?'checked':''}>女
						</td>
					</tr>
					<tr>
						<td>关注类型</td>
						<td>
							<input type="checkbox" name="type" value="法律法规">法律法规
							<input type="checkbox" name="type" value="管理办法">管理办法
							<input type="checkbox" name="type" value="决定条例">决定条例
							<input type="checkbox" name="type" value="细则解释">细则解释
							<input type="checkbox" name="type" value="规范指南">规范指南
						</td>
						<c:forEach items="${types}" var = "type">
							<script type="text/javascript">
								$(":checkbox[value=${type}]").attr("checked","true");
							</script>
						</c:forEach>
					</tr>
					<tr>
						<td colspan='2' style="text-align:center">
							<input type="submit" value="保存修改"/>
							<input type="button" value="返回" onclick="location.reload()"/>
						<td>
					</tr>
				</table>
			</form>
		</c:otherwise>
	</c:choose>
</html>